<template>
	<view class="wrap">
		<view class="banner">
			<swiper class="swiper" circular  indicator-color="rgba(255,255,255,0.5)" indicator-active-color="#FFF" :autoplay="true">
				<swiper-item>
					<view class="swiper-item">
						<view class="swiper-item-one">
							<u--image
							:src="imgDomain+'/admin-api/infra/file/4/get/13bc11b8c23227954e646d153f44c42ed09ea0e005ae22709847b51f5623aaf9.png'"
							:showLoading="true" width="750rpx" height="400rpx" mode="widthFix"
							>
								<template v-slot:loading>
								   <u-loading-icon ></u-loading-icon>
								</template>
							</u--image>
							<image class="guohui_img" :src="imgDomain+'/admin-api/infra/file/4/get/fbeef4fffc08ee3d350ff52fec8c5fdc7c6620d5297444294a5609d9e7b59dba.png'" mode="widthFix"></image>
							<view class="guohui_text">国家企业信用信息公示系统(宁夏)</view>
						</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<view class="content">
			<view class="min" @click="showNoFun()">
				<u--image 
				:src="imgDomain+'/admin-api/infra/file/4/get/66152cc250e6815a259ceb3a6ddce8653c4858e0015abea07a7b3fb83512d639.png'"
				:showLoading="true" width="100%" height="100%" radius="10rpx" mode="widthFix"
				>
					<template v-slot:loading>
					   <u-loading-icon ></u-loading-icon>
					</template>
				</u--image>
			</view>
			
			<view class="min" v-for="item,index in list" :key="index" @click="goInform(item)">
				<u--image  :src="imgDomain+item.src" :showLoading="true" width="100%" height="100%" radius="10rpx" mode="widthFix">
					<template v-slot:loading>
					   <u-loading-icon ></u-loading-icon>
					</template>
				</u--image>
			</view>
			
			<view class="button_wrap">
				<view v-if="token" class="btn" @click="loginOut()">退出登录</view>
				<view v-else class="btn" @click="goLogin('/pages/login/login')">立即登录</view>
			</view>
			
		</view>
	</view>
</template>

<script>
import {outLogin} from '@/common/login.js'
export default {
	data() {
		return {
			parentRegnoInfo: this.$store.state.parentRegnoInfo,
			imgDomain: this.$config.imgDomain,
			token: '',
			list: [
				{name: '个体工商', ruleType: true, id: '9600', src:'/admin-api/infra/file/4/get/d52d8213af29f201c8dabdb5d4d6ec29e5b1a4e55116e6e5c740ddd132b91748.png'},
				{name: '企业', ruleType: false, id: '9600,9100', src:'/admin-api/infra/file/4/get/2f9dec460d39c421ecf6818c30f4a75ab554030a336c4837760b1e514d26a64a.png'},
				{name: '农专', ruleType: true, id: '9100', src:'/admin-api/infra/file/4/get/a34b0ad510849161b292c1a9def5afb0cb05fc2f44c8302e5869175c99ea588f.png'},
			],
		}
	},
	onLoad() {
		
	},
	onShow() {
		this.token = this.$store.state.token;
	},
	methods: {
		showNoFun(){
			this.$util.showToast({title: '开发中'})
		},
		loginOut(){
			this.$http.sendRequest({
				url: '/annual/report/entuser/logout',
				method: 'POST'
			})
			.then(res=>{
				outLogin();
				uni.showModal({
					title: '提示',
					content: '退出登录成功',
					showCancel: false,
					success(res) {
						if(res.confirm){
							uni.reLaunch({
								url: '/pages/index/index'
							})
						}
					}
				})
			})
			.catch(err=>{})
			
			
		},
		goInform(item){
			let token = this.$store.state.token;
			let parentRegnoInfo = this.$store.state.parentRegnoInfo;
			if(!token){
				uni.navigateTo({
					url: '/pages/login/login?returnState=true'
				})
				setTimeout(()=>{
					this.$util.showToast({title: '请进行登录'})
				},500)
				return;
			}else{
				let ruleSta = false;
				let arr = item.id.split(',');
				if(item.ruleType){
					for(let i=0; i<arr.length; i++){
						if(parentRegnoInfo.enttype == arr[i]){
							ruleSta = true;
							break;
						}
					}
				}else{
					let num = 0;
					for(let i=0; i<arr.length; i++){
						if(parentRegnoInfo.enttype == arr[i]){
							num += 1;
						}
					}
					ruleSta = num>0?false:true;
				}
				
				if(ruleSta){
					uni.navigateTo({
						url: '/pages/annals/inform'
					})
				}else{
					uni.showModal({
						title: '提示',
						content: '当前登录账号非此类型，无法填报！',
						showCancel: false,
					})
				}
			}
		},
		goLogin(path){
			uni.navigateTo({
				url: path
			})
		}
	}
}
</script>

<style lang="less">

.wrap{
	width: 100vw;
	min-height: 100vh;
	padding-bottom: 150rpx;
	position: relative;
}

.banner {
	width: 100%;
	
	.swiper{
		height: 400rpx;
		
		.swiper-item{
			height: 100%;
			
			.swiper-item-one{
				width: 100%;
				height: 100%;
				position: relative;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				
				.u-image{
					position: absolute;
					left: 0;
					top: 0;
				}
				.guohui_img{
					width: 200rpx;
					height: 220rpx;
					z-index: 2;
				}
				.guohui_text{
					font-size: 36rpx;
					font-weight: bold;
					color: #A67315;
					z-index: 2;
					margin-bottom: -30rpx;
					margin-top: 20rpx;
				}
			}
			
			image {
				width: 100%;
				display: block;
			}
		}
	}
}

.content{
	width: 690rpx;
	margin: 40rpx auto;
}


.min{
	width: 690rpx; 
	min-height: 180rpx;
	margin-bottom: 40rpx;
}

.button_wrap{
	display: flex;
	justify-content: center;
	padding-top: 50rpx;
	
	.btn{
		font-weight: 600;
		font-size: 36rpx;
		color: #A67315;
	}
}


</style>
